#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <netinet/in.h>
#include "Packet.h"

#ifndef CODEC_H_
#define CODEC_H_

unsigned long encodeLong(unsigned long src, char *dst);
unsigned long decodeLong(char *src, unsigned long *dst);

char *encode_PacketHeader(PACKET_HEADER *head, unsigned long *length);
PACKET_HEADER *decode_PacketHeader(char *buf, unsigned long *length);

char *encode_MSG_LOGIN_REQ_DATA(PACKET_DATA *data, unsigned long *length);
char *encode_MSG_LOGIN_ACK_DATA(PACKET_DATA *data, unsigned long *length);

char *encode_PacketData(PACKET_DATA *data, unsigned long *length, PACKET_HEADER *head);
PACKET_DATA *decode_PacketData(char *buffer, unsigned long *length, PACKET_HEADER *head);

char encode_Packet(PACKET *packet, unsigned long *length);
PACKET *decode_PACKET(char *buffer, unsigned long *length);

#endif

